

import {render,connect} from '../../../../../hrpub/common/frame';
import { base } from 'nc-lightapp-front';
import BtnAction from '../../actions/btn.js'
import TempAction from '../../actions/temp.js'
import ReferSearch from'../../../../../hrpub/common/components/referSearch/org'
import Emptyimg from '../../../../../hrpub/common/components/emptyImg/index.js'
import PubAction from '../../actions/pub';
import Pagination from '../../../../../hrpub/common/components/Pagination'



const Table = render({
  actions: {
      btnAction : BtnAction,
      tempAction : TempAction,
      pubAction : PubAction
  }

})(({props, action, state}) => {
    const{editTable,button,main} = props
    const{createEditTable} = editTable
    const{createButtonApp} = button
    const { NCTabs } = base;
    const NCTabPane = NCTabs.NCTabPane;

    const dom = main.orgvalue.refpk ?
        <React.Fragment>
            <NCTabs navtype="turn" contenttype="moveleft" defaultActiveKey="1" onChange = {action.tempAction.onPaneChange}>
                <NCTabPane tab={main.json['gx6008-000075']} key="1"> 
                    {createEditTable('handcondgrid',{
                        showCheck: true,
                        onSelected : action.tempAction.onTableSelected,
                        onSelectedAll : action.tempAction.onTableonSelectedAll,
                        onRowDoubleClick: action.tempAction.onRowDoubleClick,
                        adaptionHeight:true,
                        cancelCustomRightMenu: true
                    })}
                </NCTabPane>
                <NCTabPane tab={main.json['gx6008-000076']} key="2">
                    {createEditTable('dishandcondgrid',{
                        showCheck: true,
                        onSelected : action.tempAction.onTableSelected,
                        onSelectedAll : action.tempAction.onTableonSelectedAll,
                        onRowDoubleClick: action.tempAction.onRowDoubleClick,
                        adaptionHeight:true,
                        cancelCustomRightMenu: true
                    })}
                    </NCTabPane>
                </NCTabs>
        </React.Fragment> : <Emptyimg text={main.json['gx6008-000077']} />

    return(
        <React.Fragment>
            <div style={{display: main.showPage === 'list'? '':'none'}} className="nc-bill-card">
                <div className="header">
                    <div className="header-seach">
                    <ReferSearch
                        orgVal={main.orgvalue}
                        getOrgData={action.tempAction.changeOrg}
                    />
                    </div>
                    <div className= "header-btn">
                        {createButtonApp({
                            area: 'list',
                            onButtonClick : action.btnAction.onButtonClick
                        })}
                    </div>
                </div>
                <div className="body-tab">  
                   {dom}
                </div> 
                <div style={{paddingTop:10}}>
                    {main.pageInfo.total ?<Pagination
                        total = {main.pageInfo.total}
                        pageSize = {main.pageInfo.pageSize}
                        showQuickJumper ={true}
                        showSizeChanger = {true}
                        onChange = {action.btnAction.paginationEve}
                        onShowSizeChange = {action.btnAction.pageSizeSelect}
                        showSizeInput = {true}
                    /> : null}
                </div>     
            </div>
        </React.Fragment>
    )

})

export default connect(Table)